package com.hhlkeepalive.resident;

import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import com.hhlkeepalive.R;
import java.util.Timer;
import java.util.TimerTask;

public class ResidentService extends Service{
    private int tag=1;
    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("TAG","服务开始了");

        //还存活的标志
        Timer timer=new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                Log.e("TAG","计数器"+tag);
                tag++;
            }
        },0,3000);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Notification notification = new Notification(R.mipmap.ic_launcher, "有消息来了"
                , System.currentTimeMillis());
        notification.flags = Notification.FLAG_SHOW_LIGHTS;
        this.startForeground(10,notification);
        return START_STICKY;
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }


}
